<template>
  <div>
    <div class="tooltip" v-if="visible">
      <div class="tooltip-content" v-html="content"></div>
    </div>
    <div
      class="tooltip-trigger"
      @mouseenter="showTooltip"
      @mouseleave="hideTooltip"
    >
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      content: ''
    }
  },
  methods: {
    showTooltip() {
      this.visible = true
    },
    hideTooltip() {
      this.visible = false
    }
  },
  mounted() {
    this.content = this.$slots.default[0].text
  }
}
</script>

<style scoped>
.tooltip {
  position: relative;
}

.tooltip-content {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #fff;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tooltip-trigger {
  display: inline-block;
  cursor: pointer;
}
</style>
